Try to preserve Ozi icon data in waypoints.
authorrobertl <robertl>
Sun, 28 Jun 2009 18:03:06 +0000 (18:03 +0000)
committerrobertl <robertl>
Sun, 28 Jun 2009 18:03:06 +0000 (18:03 +0000)
ozi.c

diff --git a/ozi.c b/ozi.c
index 04ebf4afff7b7b5a4f0a56e9b53d29b99b05ded9..95418879d880a61aadcca5979009eb58270b9fa9 100644 (file)
--- a/ozi.c
+++ b/ozi.c
@@ -484,7 +484,14 @@ ozi_parse_waypt(int field, char *str, waypoint * wpt_tmp, ozi_fsdata *fsdata)
        ozi_set_time_str(str, wpt_tmp);
         break;
     case 5:
-        /* icons 0-xx */
+        /* icons 0-xx.   Ozi seems to use some kind of internal tables to
+          pick numbers for icons based on GPS type.  We don't know what those
+           tables are, so we read just the numbers.  This converts badly to
+           other types, but it at least maintains fidelity for an ozi->ozi 
+           operation. */
+       if (str && isdigit(str[0])) {
+           wpt_tmp->icon_descr = xstrdup(str);
+        }
         break;
     case 6:
         /* unknown - always 1 */
@@ -803,6 +810,7 @@ ozi_waypt_pr(const waypoint * wpt)
     char *shortname;
     int faked_fsdata = 0;
     ozi_fsdata *fs = NULL;
+    int icon = 0;
 
     fs = (ozi_fsdata *) fs_chain_find(wpt->fs, FS_OZI);
 
@@ -845,9 +853,13 @@ ozi_waypt_pr(const waypoint * wpt)
 
     index++;
 
+    if(wpt->icon_descr && isdigit(wpt->icon_descr[0])) {
+        icon = atoi(wpt->icon_descr);
+    }
+
     gbfprintf(file_out,
             "%d,%s,%.6f,%.6f,%s,%d,%d,%d,%d,%d,%s,%d,%d,",
-            index, shortname, wpt->latitude, wpt->longitude, ozi_time, 0,
+            index, shortname, wpt->latitude, wpt->longitude, ozi_time, icon,
             1, 3, fs->fgcolor, fs->bgcolor, description, 0, 0);
     if (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0))
        gbfprintf(file_out, "%.1f,", wpt->proximity * prox_scale);